programacaofandomcom-20200223-history
Actionscript
Olá Gente To create the HelloWorld project and Greeter class in Flex: # In Flash Builder, select File > New> Flex Project, # Type HelloWorld as the Project Name. Make sure that the Application type is set to “Web (runs in Adobe Flash Player),” and then click Finish. Flash Builder creates your project and displays it in the Package Explorer. By default the project already contains a file named HelloWorld.mxml, and that file is open in the editor. # Now to create a custom ActionScript class file in Flash Builder, select File > New > ActionScript Class. # In the New ActionScript Class dialog box, in the Name field, type Greeter as the class name, and then click Finish. A new ActionScript editing window is displayed. Continue with Adding code to the Greeter class. Para Criar a classe Greeter no Flash Professional: No Flash Professional, seleccione o Ficheiro > Novo. Na janela do Novo Documento, seleccione o ficheiro ActionScript e carregue EM OK. Uma Nova janela de edição do ActionScript é exibida. Selecionar arquivo > Salvar.Selecione UMA pasta para conter SUA aplicação, nomeie o arquivo ActionScript Greeter.as, e então clique EM OK. Adicione este código para o novo ficheiro: package { public class Greeter { public function sayHello():String { var greeting:String; greeting = "Hello World!"; return greeting; } } }Selecionar arquivo > Salvar para salvar este arquivo ActionScript. Selecionar File > New. Na janela do Novo Documento, seleccione Flash File (ActionScript 3.0), e carregue EM OK. É apresentada UMA Nova janela de documento. Select File > Save. Selecione a mesma pasta que contém o arquivo Greeter.as classe, nomeie o documento Flash HelloWorld.fla, e clique EM OK. Na paleta de ferramentas profissionais Flash, selecione a ferramenta de texto.Arraste através do estágio para definir um novo Campo de texto aproximadamente 300 pixels de largura e 100 pixels de altura. No painel de Propriedades, com o Campo de texto ainda selecionado Na Fase, defina o Tipo de texto para "Texto Dinâmico". Clique no primeiro Quadro Da Linha temporal principal.Abre o painel de Acções escolhendo as Ações Da Janela > Name No painel de Acções, escreva o seguinte script: var myGreeter:Greeter = new Greeter(); mainText.text = myGreeter.sayHello(); Abre o ficheiro HelloWorld.mxml e adiciona o código para corresponder à seguinte lista: private var myGreeter:Greeter = new Greeter(); public function initApp():void { // says hello at the start, and asks for the user's name mainTxt.text = myGreeter.sayHello(); } * To publish and test an ActionScript application using Flash Professional: *# Publish your application and watch for compilation errors. In Flash Professional, select Control > Test Movie to compile your ActionScript code and run the HelloWorld application. *# If any errors or warnings are displayed in the Output window when you test your application, fix these errors in the HelloWorld.fla or HelloWorld.as files. Then try testing the application again. *# If there are no compilation errors, you see a Flash Player window showing the Hello World application. You have created a simple but complete object-oriented application that uses ActionScript 3.0. Continue with Enhancing the HelloWorld application. To publish and test an ActionScript application using Flash Builder: *# Select Run > Run HelloWorld. *# The HelloWorld application starts. *#* If any errors or warnings are displayed in the Output window when you test your application, fix the errors in the HelloWorld.mxml or Greeter.as files. Then try testing the application again. *#* If there are no compilation errors, a browser window opens showing the Hello World application. The text “Hello World!” appears. You have created a simple but complete object-oriented application that uses ActionScript 3.0. Continue with Enhancing the HelloWorld application.